package homwork4_8.dao.impl;


import homwork4_8.dao.BaseDao;
import homwork4_8.dao.ILogDao;
import homwork4_8.service.impl.User;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.time.LocalDate;

public class LogDaoImpl extends BaseDao implements ILogDao {
    private static  String s ;
    private static  String arrayInfo;
    private LocalDate date = LocalDate.now();
    private static String nullInfo;
    @Override
    public void run() {
        int[] x = {1,2,3};
        try {
            for(int i = 0;i<=x.length;i++){
                System.out.println(x[i]);
            }
        }
        catch (Exception e){
           s = e.toString();
            System.out.println(s);
            int y = s.indexOf(":");
            arrayInfo =   s.substring(0,y);
            System.out.println(arrayInfo);
        }
        this.update("insert into t_log(l_info,l_date) value(?,?)",arrayInfo,date);
    }

    @Override
    public void work() {
        String text = null;
        try {
            InputStream is =new ByteArrayInputStream(text.getBytes("UTF-8"));
        } catch (Exception e) {
            nullInfo = e.toString();
            System.out.println(nullInfo);
        }
        this.update("insert into t_log(l_info,l_date) value(?,?)",nullInfo,date);
    }

    @Override
    public void sleep() {

    }

    public static void main(String[] args) {
        ILogDao i = new LogDaoImpl();
        i.run();
        i.work();
    }
}
